<template>
	<view class="smart-form">
		<uni-forms :label-width="100" ref="formRef" :modelValue="formData" label-position="left" :rules="rules">


			<view class="smart-form-group smart-filed">
				<view class="smart-form-group-title smart-margin-top20"> 客户基本信息</view>
				<view class="smart-form-group-content">

					<uni-forms-item class="smart-form-item smart-margin-top15" label="身份证正面" name="idCardFace" required>
						<uni-file-picker limit="1" @select='selectUploadByIdCardFace' :auto-upload='false'
							file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image" v-model='formData.idCardFace' />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top15" label="身份证反面（国徽）" name="idCardBack"
						required>
						<uni-file-picker limit="1" @select='selectUploadByIdCardBack' :auto-upload='false'
							file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image" v-model='formData.idCardBack' />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="姓名" name="customerName" required>
						<uni-easyinput trim="all" v-model="formData.customerName" placeholder="请输入姓名" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="手机号码" name="mobileNo" required>
						<uni-easyinput trim="all" v-model="formData.mobileNo" placeholder="请输入手机号码" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="身份证号" name="idCard" required>
						<uni-easyinput trim="all" v-model="formData.idCard" placeholder="身份证号" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="婚姻状况" name="maritalStatus" required>
						<DictSelect keyCode="CD000400" v-model="formData.maritalStatus" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="当前居住地址" name="residentialAddress" required>
						<view class="sdd" style="display: flex;">
							<uni-data-select :localdata="provinceData" @change="provincechange" placeholder="选择省"
								style="width: 100%;"></uni-data-select>
							<uni-data-select :localdata="cityData" @change="citychange" placeholder="选择市区"
								style="width: 100%;"></uni-data-select>
						</view>
						<view class="sdd" style="display: flex;">
							<uni-data-select :localdata="areaData" @change="areachange" placeholder="选择区县"
								style="width: 100%;"></uni-data-select>
							<uni-data-select :localdata="streetData" @change="streetchange" placeholder="选择镇"
								style="width: 100%;"></uni-data-select>
						</view>
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="当前居住详细地址" name="residentialDetailAddress" required>
						<uni-easyinput trim="all" v-model="formData.residentialDetailAddress"
							placeholder="请输入当前居住详细地址" />
					</uni-forms-item>


					<!-- 		<uni-forms-item class="smart-form-item" label="工作年限" name="workingYears" required>
						<DictSelect keyCode="GZNX000100" v-model="formData.workingYears" />
					</uni-forms-item> -->
					<uni-forms-item class="smart-form-item" label="本人月收入" name="monthlyIncome" required>
						<uni-easyinput trim="all" v-model="formData.monthlyIncome" placeholder="请输入本人月收入" />
					</uni-forms-item>
					<!-- 新增字段开始 -->
					<uni-forms-item class="smart-form-item smart-margin-top20" label="学历" name="educational" required>
						<uni-data-select v-model="formData.educational" :localdata="educationalData" @change="change"
							placeholder="请选择学历" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="单位电话" name="workTelephone" required>
						<uni-easyinput trim="all" v-model="formData.workTelephone" placeholder="请输入单位电话" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="如有邮寄您期望寄至" name="mailingAddress" required>
						<!-- <uni-easyinput trim="all" v-model="formData.mailingAddress" placeholder="请输入邮寄地址" /> -->
						<uni-data-select v-model="formData.mailingAddress" :localdata="mailingAddresslData"
							@change="change" placeholder="请选择邮寄地址类型" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="本地户口" name="localHouseholdRegistration" required>
						<uni-data-checkbox mode="button" v-model="formData.localHouseholdRegistration"
							:localdata="localHouseholdRegistrationArr"></uni-data-checkbox>
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="新市民" name="newCitizen" required>
						<uni-data-checkbox mode="button" v-model="formData.newCitizen"
							:localdata="newCitizenArr"></uni-data-checkbox>
					</uni-forms-item>

					<!-- 新增字段结束 -->
				</view>
			</view>
			<!-- 职业申请人信息模块开始 -->
			<view class="smart-form-group smart-filed">
				<view class="smart-form-group-title">
					申请人职业信息
				</view>
				<view class="smart-form-group-content">
					<uni-forms-item class="smart-form-item" label="工作单位" name="workUnit" required>
						<uni-easyinput trim="all" v-model="formData.workUnit" placeholder="请输入工作单位" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="单位所属行业" name="unitIndustry"
						required>
						<uni-data-select v-model="formData.unitIndustry" :localdata="unitIndustryData" @change="change"
							placeholder="请选择所属行业" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="从业经验" name="workExperience"
						required>
						<uni-data-select v-model="formData.workExperience" :localdata="workExperienceData"
							@change="change" placeholder="请选择从业经验" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="工作年限" name="workYears" required>
						<uni-data-select v-model="formData.workYears" :localdata="workYareData" @change="change"
							placeholder="请选择工作年限" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="单位地址" name="posApplicantAddress"
						required>
						<!-- 	<uni-data-picker placeholder="单位地址" popup-title="单位地址" :localdata="dataTree"
							v-model="formData.posApplicantAddress" @change="posApplicantAddressonChange">
						</uni-data-picker> -->
						<view class="sdd" style="display: flex;">
							<uni-data-select :localdata="provinceData2" @change="provincechange2" placeholder="选择省"
								style="width: 100%;"></uni-data-select>
							<uni-data-select :localdata="cityData2" @change="citychange2" placeholder="选择市区"
								style="width: 100%;"></uni-data-select>
						</view>
						<view class="sdd" style="display: flex;">
							<uni-data-select :localdata="areaData2" @change="areachange2" placeholder="选择区县"
								style="width: 100%;"></uni-data-select>
							<uni-data-select :localdata="streetData2" @change="streetchange2" placeholder="选择镇"
								style="width: 100%;"></uni-data-select>
						</view>
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="单位详情地址"
						name="posApplicantDtetailAddress" required>
						<uni-easyinput trim="all" v-model="formData.posApplicantDtetailAddress"
							placeholder="请输入单位详情地址" />
					</uni-forms-item>

				</view>
			</view>
			<!-- 职业申请人信息模块结束 -->
			<view class="smart-form-group smart-filed" v-if="formData.maritalStatus === '9105'">
				<view class="smart-form-group-title"> 配偶信息</view>
				<view class="smart-form-group-content">
					<uni-forms-item class="smart-form-item" label="姓名" name="spouseName" required>
						<uni-easyinput trim="all" v-model="formData.spouseName" placeholder="请输入配偶姓名" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="身份证号码" name="spouseIdCard" required>
						<uni-easyinput trim="all" v-model="formData.spouseIdCard" placeholder="请输入配偶身份证号码" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="手机号码" name="spouseMobileNo" required>
						<uni-easyinput trim="all" v-model="formData.spouseMobileNo" placeholder="请输入配偶手机号码" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="月收入" name="spouseMonthlyIncome" required>
						<uni-easyinput trim="all" v-model="formData.spouseMonthlyIncome" placeholder="请输入配偶月收入" />
					</uni-forms-item>

					<uni-forms-item class="smart-form-item" label="单位地址" name="workAddress" required>
						<uni-easyinput trim="all" v-model="formData.workAddress" placeholder="请输入配偶月收入" />
					</uni-forms-item>

					<uni-forms-item class="smart-form-item" label="单位详细地址" name="workAddress" required>
						<uni-easyinput trim="all" v-model="formData.workAddress" placeholder="请输入单位地址" />
					</uni-forms-item>
				</view>
			</view>
			<view class="smart-form-group smart-filed">
				<view class="smart-form-group-title">
					<!-- 亲友信息 -->
					联系人信息
				</view>
				<view class="smart-form-group-content">
					<uni-forms-item class="smart-form-item" label="亲友姓名" name="relativeName" required>
						<uni-easyinput trim="all" v-model="formData.relativeName" placeholder="请输入亲友姓名" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="亲友手机号" name="relativeMobileNo" required>
						<uni-easyinput trim="all" v-model="formData.relativeMobileNo" placeholder="请输入亲友手机号" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="与申请人关系" name="relationType" required>
						<DictSelect keyCode="CD011900" v-model="formData.relationType" clear />
					</uni-forms-item>


					<uni-forms-item class="smart-form-item" label="紧急联系人" name="otherRelativeName" required>
						<uni-easyinput trim="all" v-model="formData.otherRelativeName" placeholder="请输入紧急联系人" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="紧急联系人手机号" name="otherRelativeMobileNo" required>
						<uni-easyinput trim="all" v-model="formData.otherRelativeMobileNo" placeholder="请输入紧急联系人手机号" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="与申请人关系" name="otherRelationType" required>
						<DictSelect keyCode="CD011900" v-model="formData.otherRelationType" clear />
					</uni-forms-item>
				</view>
			</view>
			<!-- 新增模块开始 -->
			<view class="smart-form-group smart-filed">
				<view class="smart-form-group-title"> 驾照持有人信息</view>
				<view class="smart-form-group-content">
					<uni-forms-item class="smart-form-item" label="持有人姓名" name="possessorName" required>
						<uni-easyinput trim="all" v-model="formData.possessorName" placeholder="请输入持有人姓名" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="与申请人关系"
						name="relationshipApplicant" required>
						<uni-data-select v-model="formData.relationshipApplicant" :localdata="relationshipApplicantData"
							@change="change" placeholder="请选择与申请人关系" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="证件类型"
						name="possessCertificateType" required>
						<uni-data-select v-model="formData.possessCertificateType"
							:localdata="possessCertificateTypeData" @change="change" placeholder="请选择证件类型" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="证件号码" name="possessCardId" required>
						<uni-easyinput trim="all" v-model="formData.possessCardId" placeholder="请输入证件号码" />
					</uni-forms-item>
				</view>
			</view>
			<!-- 新增模块结束 -->
			<view class="smart-form-group smart-filed">
				<view class="smart-form-group-title"> 车辆信息</view>
				<view class="smart-form-group-content">
					<uni-forms-item class="smart-form-item" label="车辆类型" name="vehicleBusinessType" required>
						<smart-enum-select v-model="formData.vehicleBusinessType"
							enumName="VEHICLE_LOAN_ORDER_BUSINESS_TYPE_ENUM" @change="vehicleBusinessTypechange" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="公里数" name="mile"
						v-if="formData.vehicleBusinessType === 1" required>
						<uni-easyinput trim="all" v-model="formData.mile" placeholder="请输入公里数" />
					</uni-forms-item>
<!-- 					<uni-forms-item class="smart-form-item" label="系数" name="rate" required>
					</uni-forms-item> -->
			<!-- 		<uni-forms-item class="smart-form-item" label="贷款金额" name="loanAmount" required>
						<uni-easyinput trim="all" v-model="formData.loanAmount" placeholder="请输入贷款金额" />
					</uni-forms-item> -->

					<uni-forms-item class="smart-form-item smart-margin-top15" label="行驶证" name="drivingPermit"
						v-if="formData.vehicleBusinessType === 1" required>
						<uni-file-picker limit="1" @select='selectUploadByDrivingPermit' :auto-upload='false'
							file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image"
							v-model='formData.drivingPermit' />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="车辆登记证书"
						name="vehicleRegistrationCertificate" v-if="formData.vehicleBusinessType === 1" required>
						<uni-file-picker limit="5" @select='selectUploadByVehicleRegistrationCertificate'
							:auto-upload='false' file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image"
							v-model='formData.vehicleRegistrationCertificate' />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="上牌省份"
						name="issueAuthorityProvince" v-if="formData.vehicleBusinessType === 1" required>
						<uni-data-select :localdata="provinceOptions" v-model="formData.issueAuthorityProvince"
							placeholder="请选择上牌省份" @change="selectProvince" :clear="false" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="上牌城市" name="issueAuthorityCity"
						v-if="formData.vehicleBusinessType === 1" required>
						<uni-data-select :localdata="cityOptions" v-model="formData.issueAuthorityCity"
							placeholder="请选择上牌城市" :disabled="formData.issueAuthorityProvince === undefined"
							:clear="false" />
					</uni-forms-item>
<!-- 					<uni-forms-item class="smart-form-item" label="车商" name="vehicleDealers" required>
						<uni-easyinput trim="all" v-model="formData.vehicleDealers" placeholder="请输入车商信息" />
					</uni-forms-item> -->
		<!-- 			<uni-forms-item class="smart-form-item" label="驾驶证持有人信息" name="drivingLicenseOwnerType" required>
						<uni-easyinput trim="all" v-model="formData.drivingLicenseOwnerType"
							placeholder="请输入驾驶证持有人信息" />
					</uni-forms-item> -->
					<uni-forms-item class="smart-form-item smart-margin-top15" label="驾驶证" name="drivingLicense"
						required>
						<uni-file-picker limit="3" @select='selectUploadByDrivingLicense' :auto-upload='false'
							file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image"
							v-model='formData.drivingLicense' />
					</uni-forms-item>

				</view>
			</view>

			<!-- 新增模块2开始 -->
			<!-- 			<view class="smart-form-group smart-filed">
				<view class="smart-form-group-title"> 贷款信息</view>
				<view class="smart-form-group-content">
					<uni-forms-item class="smart-form-item" label="售方名称" name="sellerName" required>
						<uni-easyinput trim="all" v-model="formData.sellerName" placeholder="请输入售方名称" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="合作模式" name="cooperationMode"
						required>
						<uni-data-select v-model="formData.cooperationMode" :localdata="cooperationModeData"
							@change="change" placeholder="请选择合作模式" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="贷款政策" name="lendingPolicy"
						required>
						<uni-data-select v-model="formData.lendingPolicy" :localdata="lendingPolicyData"
							@change="change" placeholder="请选择贷款政策" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="贷款期数" name="loadInstalments" required>
						<uni-easyinput trim="all" v-model="formData.loadInstalments" placeholder="请输入贷款期数" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="产品名称" name="productName" required>
						<uni-data-select v-model="formData.productName" :localdata="productNameData" @change="change"
							placeholder="请选择产品类型" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="是否挂靠" name="getAttached" required>
						<uni-data-select v-model="formData.getAttached" :localdata="getAttachedData" @change="change"
							placeholder="是否靠挂" />
					</uni-forms-item>

					<uni-forms-item class="smart-form-item smart-margin-top20" label="是否免抵押" name="isMortgage" required>
						<uni-data-select v-model="formData.isMortgage" :localdata="ismortgageData" @change="change"
							placeholder="是否免抵押" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="安心贷政策" name="anxinLoan" required>
						<uni-data-select v-model="formData.anxinLoan" :localdata="AnxinLoanData" @change="change" />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item smart-margin-top20" label="是否贴息" name="isSoftLoan" required>
						<uni-data-select v-model="formData.isSoftLoan" :localdata="issoftLoanData" @change="change" />
					</uni-forms-item>

					<uni-forms-item class="smart-form-item smart-margin-top20" label="差异化利率档次"
						name="interestRateBracket" required>
						<uni-data-select v-model="formData.interestRateBracket" :localdata="interestRateBracketData"
							@change="change" />
					</uni-forms-item>

				</view>
			</view> -->
			<!-- 新增模块2结束 -->
			<view class="smart-form-group">
				<view class="smart-form-group-title"> 上传图片</view>
				<view class="smart-form-group-content">
					<uni-forms-item class="smart-form-item smart-margin-top15" label="关系证明" name="relationProof">
						<uni-file-picker limit="5" @select='selectUploadByRelationProof' :auto-upload='false'
							file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image"
							v-model='formData.relationProof' />
					</uni-forms-item>
					<uni-forms-item class="smart-form-item" label="其他收入类证明" name="otherIncomeProof">
						<uni-file-picker limit="5" @select='selectUploadByOtherIncomeProof' :auto-upload='false'
							file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image"
							v-model='formData.otherIncomeProof' />
					</uni-forms-item>
				</view>
			</view>
		</uni-forms>

		<view class="smart-form-submit fixed-bottom-button">
			<button class="smart-form-submit-btn" type="primary" @click="ok" :disabled="submitting">
				{{ submitting ? '提交中...' : '提交' }}
			</button>
		</view>
	</view>
</template>

<script setup>
	import {
		onMounted,
		reactive,
		ref,
		watchEffect,

	} from 'vue';
	import {
		onShow
	} from '@dcloudio/uni-app';
	import utils from '@/utils/utils.js'
	import SmartEnumSelect from '@/components/smart-enum-select/index.vue';
	import {
		regular
	} from '@/constants/regular-const';
	import {
		vehicleLoanOrderApi
	} from '@/api/business/qr/vehicle-loan-order-api';
	import {
		SmartLoading,
		SmartToast
	} from "../../lib/smart-support";
	import {
		smartSentry
	} from "../../lib/smart-sentry";
	import DictSelect from '@/components/dict-select/index.vue';
	import {
		fileApi
	} from "/@/api/support/file-api";
	import {
		fileOcrApi
	} from "/@/api/support/file-ocr-api";
	import {
		FILE_FOLDER_TYPE_ENUM
	} from "../../constants/support/file-const";
	// 学历数据源
	const educationalData = ref([{
			value: 0,
			text: "研究生(含)以上"
		},
		{
			value: 1,
			text: "本科"
		},
		{
			value: 2,
			text: "大专"
		},
		{
			value: 3,
			text: "高中、中专"
		}, {
			value: 4,
			text: "初中(含)含以下"
		}
	])

	// 本地户口数据源
	const localHouseholdRegistrationArr = ref([{
		text: '否',
		value: 0
	}, {
		text: '是',
		value: 1
	}])

	// 新市民数据源
	const newCitizenArr = ref([{
		text: '否',
		value: 0
	}, {
		text: '是',
		value: 1
	}])


	// 单位所属行业数据源
	const unitIndustryData = ref([{
			value: 1,
			text: "农、林、牧、渔业"
		},
		{
			value: 2,
			text: "采矿业"
		},
		{
			value: 3,
			text: "制造业"
		},
		{
			value: 4,
			text: "电力、燃气及水的生产和供应业"
		},
		{
			value: 5,
			text: "建筑业"
		},
		{
			value: 6,
			text: "交通运输、仓储和邮政业"
		},
		{
			value: 7,
			text: "信息传输、计算机服务和软件业"
		},
		{
			value: 8,
			text: "批发和零售业"
		},
		{
			value: 9,
			text: "住宿和餐饮业"
		},
		{
			value: 10,
			text: "金融业"
		},
		{
			value: 11,
			text: "房地产业"
		},
		{
			value: 12,
			text: "租赁和商务服务业"
		},
		{
			value: 13,
			text: "科学研究、技术服务和地质勘查业"
		},
		{
			value: 14,
			text: "水利、环境和公共设施管理业"
		},
		{
			value: 15,
			text: "居民服务和其他服务业"
		},
		{
			value: 16,
			text: "教育"
		},
		{
			value: 17,
			text: "卫生、社会保障和社会福利业"
		},
		{
			value: 18,
			text: "文化、体育和娱乐业"
		},
		{
			value: 19,
			text: "公共管理和社会组织"
		},
		{
			value: 20,
			text: "国际组织"
		}
	]);
	// 从业经验数据源
	const workExperienceData = ref([{
			value: 1,
			text: "现单位或本行业连续从业3（含）年以上"
		},
		{
			value: 2,
			text: "现单位或本行业连续从业1-3年"
		},
		{
			value: 3,
			text: "其他"
		}
	])
	// 邮寄地址下拉数据源
	const mailingAddresslData = ref([{
			value: 1,
			text: "单位地址"
		},
		{
			value: 2,
			text: "家庭地址"
		}
	])

	// 工作年限数据源
	const workYareData = ref([{
			value: 1,
			text: "10年以上"
		},
		{
			value: 2,
			text: "5(含)～10年"
		},
		{
			value: 3,
			text: "3(含)～5年"
		},
		{
			value: 4,
			text: "1(含)～3年"
		},
		{
			value: 5,
			text: "1年以下"
		}
	])
	// 合作模式数据源
	const cooperationModeData = ref([{
		value: 0,
		text: '本地合作'
	}, {
		value: 1,
		text: '异地调车'
	}])
	// 与申请人关系数据源
	const relationshipApplicantData = ref([{
		value: 0,
		text: '学车证明'
	}, {
		value: 1,
		text: '本人'
	}, {
		value: 2,
		text: '直系亲属'
	}, {
		value: 3,
		text: '其他'
	}])
	// 持有人证件类型数据源
	const possessCertificateTypeData = ref([{
			value: 1,
			text: '身份证'
		},
		{
			value: 2,
			text: '临时身份证'
		},
		{
			value: 3,
			text: '军官证'
		},
		{
			value: 4,
			text: '士兵证'
		},
		{
			value: 5,
			text: '港澳居民来往内地通行证'
		},
		{
			value: 6,
			text: '台湾同胞来往内地通行证'
		},
		{
			value: 7,
			text: '外国人居留证'
		},
		{
			value: 8,
			text: '警官证'
		},
		{
			value: 9,
			text: '港澳居民居住证'
		},
		{
			value: 10,
			text: '台湾居民居住证'
		},
		{
			value: 11,
			text: '护照'
		},
		{
			value: 12,
			text: '其他证件'
		}
	]);
	// 贷款政策数据源
	const lendingPolicyData = ref([{
		value: 1,
		text: '新至尊贷-摩托车'
	}])
	// 产品名称数据源
	const productNameData = ref([{
			value: 1,
			text: '6.12-36-等额本息-10.99-q'
		},
		{
			value: 2,
			text: '6.12-36-等额本息-10.99 (摩托车置换) -q'
		},
	])
	// 是否靠挂数据源
	const getAttachedData = ref([{
			value: 1,
			text: '否'
		},
		{
			value: 2,
			text: '是'
		}
	])

	// 是否抵押数据源
	const ismortgageData = ref([{
		value: 1,
		text: '否'
	}, {
		value: 2,
		text: '是'
	}])
	// 安心贷数据源
	const AnxinLoanData = ref([{
			value: 1,
			text: '安心贷'
		},
		{
			value: 2,
			text: '无'
		}
	])
	// 获取省份下拉数据(现居住地址)
	const provinceData = ref([])
	// 获取市下拉数据(现居住地址)
	const cityData = ref([])
	// 获取区下拉数据(现居住地址)
	const areaData = ref([])
	// 获取镇下拉数据(现居住地址)
	const streetData = ref([])



	// 获取省份下拉数据(单位地址)
	const provinceData2 = ref([])
	// 获取市下拉数据(单位地址)
	const cityData2 = ref([])
	// 获取区下拉数据(单位地址)
	const areaData2 = ref([])
	// 获取镇下拉数据(单位地址)
	const streetData2 = ref([])
	// 是否贴息数据源
	const issoftLoanData = ref([{
		value: 1,
		text: '否'
	}, {
		value: 2,
		text: '是'
	}])
	// 差异化利率档次默认是新车的利率
	// 择项：新车关联（包含新车汽车/新车摩托车：10.99/11.99/12.99/13.99/14.99/15.99
	// 二手车关联（包含二手汽车/二手摩托车：15.99/16.99/17.99/18.99/19.99

	const interestRateBracketData = ref([{
			value: 1,
			text: '10.99'
		},
		{
			value: 2,
			text: '11.99'
		},
		{
			value: 3,
			text: '12.99'
		},
		{
			value: 4,
			text: '13.99'
		},
		{
			value: 5,
			text: '14.99'
		},
		{
			value: 6,
			text: '15.99' // 超过最大给定值的档次
		}
	]);

	// 选择车辆类型
	const vehicleBusinessTypechange = (val) => {
		// val== 0 或者val == 2时都是选的是新车；val == 1 时选的是二手车
		if (val == 0 || val == 2) {
			interestRateBracketData.value = [{
					value: 1,
					text: '10.99' // 假设这是描述利率档次的方式
				},
				{
					value: 2,
					text: '11.99'
				},
				{
					value: 3,
					text: '12.99'
				},
				{
					value: 4,
					text: '13.99'
				},
				{
					value: 5,
					text: '14.99'
				},
				{
					value: 6,
					text: '15.99' // 超过最大给定值的档次
				}
			]
		} else if (val == 1) {
			interestRateBracketData.value = [{
					value: 1,
					text: '15.99' // 超过最大给定值的档次
				},
				{
					value: 2,
					text: '16.99' // 超过最大给定值的档次
				},
				{
					value: 3,
					text: '17.99' // 超过最大给定值的档次
				},
				{
					value: 4,
					text: '18.99' // 超过最大给定值的档次
				},
				{
					value: 5,
					text: '19.99' // 超过最大给定值的档次
				}
			]
		}
		console.log(val, '选择车辆类型');
	}
	// 组件ref
	const formRef = ref();

	const provinceOptions = ref([]);
	const cityOptions = ref([]);

	async function selectUploadByIdCardFace(option) {
		const tempFilePaths = option.tempFilePaths;
		let res = await fileApi.uploadWithOcr(tempFilePaths[0], FILE_FOLDER_TYPE_ENUM.ID_CARD_FACE.value);
		let file = res.data.file;
		file.url = file.fileUrl;
		file.name = file.fileName;
		let idCardFaceData = res.data.idCardFaceResData;
		formData.value.idCard = idCardFaceData.idNumber;
		formData.value.customerName = idCardFaceData.name;
		// formData.value.residentialAddress = idCardFaceData.address;
		formData.value.idCardFace.push(file);
	}

	async function selectUploadByIdCardBack(option) {
		const tempFilePaths = option.tempFilePaths;
		let res = await fileApi.uploadWithOcr(tempFilePaths[0], FILE_FOLDER_TYPE_ENUM.ID_CARD_BACK.value);
		let file = res.data.file;
		file.url = file.fileUrl;
		file.name = file.fileName;
		formData.value.idCardBack.push(file);
	}

	async function selectUploadByDrivingLicense(option) {
		const tempFilePaths = option.tempFilePaths;
		let res = await fileApi.upload(tempFilePaths[0], FILE_FOLDER_TYPE_ENUM.DRIVING_LICENSE.value);
		let file = res.data;
		file.url = file.fileUrl;
		file.name = file.fileName;
		formData.value.drivingLicense.push(file);
	}

	async function selectUploadByDrivingPermit(option) {
		const tempFilePaths = option.tempFilePaths;
		let res = await fileApi.uploadWithOcr(tempFilePaths[0], FILE_FOLDER_TYPE_ENUM.DRIVING_PERMIT.value);
		let file = res.data.file;
		file.url = file.fileUrl;
		file.name = file.fileName;
		let vehicleLicenseData = res.data.vehicleLicenseResData;
		let issueAuthorityRes = await fileOcrApi.getIssueAuthority(vehicleLicenseData.issueAuthority);
		formData.value.issueAuthorityProvince = parseInt(issueAuthorityRes.data.provinceCode);
		let zoneRes = await vehicleLoanOrderApi.listByParentZoneId(formData.value.issueAuthorityProvince);
		cityOptions.value = zoneRes.data.map(item => ({
			text: item.zoneName,
			value: item.zoneId
		}));
		formData.value.issueAuthorityCity = parseInt(issueAuthorityRes.data.cityCode);
		formData.value.drivingPermit.push(file);
	}

	async function selectUploadByVehicleRegistrationCertificate(option) {
		const tempFilePaths = option.tempFilePaths;
		let res = await fileApi.upload(tempFilePaths[0], FILE_FOLDER_TYPE_ENUM.VEHICLE_REGISTRATION_CERTIFICATE.value);
		let file = res.data;
		file.url = file.fileUrl;
		file.name = file.fileName;
		formData.value.vehicleRegistrationCertificate.push(file);
		console.log(formData.value.vehicleRegistrationCertificate);
	}

	async function selectUploadByRelationProof(option) {
		const tempFilePaths = option.tempFilePaths;
		let res = await fileApi.upload(tempFilePaths[0], FILE_FOLDER_TYPE_ENUM.RELATION_PROOF.value);
		let file = res.data;
		file.url = file.fileUrl;
		file.name = file.fileName;
		formData.value.relationProof.push(file);
	}

	async function selectUploadByOtherIncomeProof(option) {
		const tempFilePaths = option.tempFilePaths;
		let res = await fileApi.upload(tempFilePaths[0], FILE_FOLDER_TYPE_ENUM.OTHER_INCOME_PROOF.value);
		let file = res.data;
		file.url = file.fileUrl;
		file.name = file.fileName;
		formData.value.otherIncomeProof.push(file);
	}

	async function queryProvinceZone() {
		let res = await vehicleLoanOrderApi.listByParentZoneId(100000);
		provinceOptions.value = res.data.map(item => ({
			text: item.zoneName,
			value: item.zoneId
		}));
	}

	async function selectProvince() {
		let res = await vehicleLoanOrderApi.listByParentZoneId(formData.value.issueAuthorityProvince);
		cityOptions.value = res.data.map(item => ({
			text: item.zoneName,
			value: item.zoneId
		}));
		formData.value.issueAuthorityCity = undefined;
	}

	const formDefault = {
		educational: undefined, //学历
		workTelephone: undefined, //单位电话
		mailingAddress: undefined, //邮寄地址
		localHouseholdRegistration: undefined, //本地户口
		newCitizen: undefined, //新市民
		unitIndustry: undefined, //单位所属行业
		workExperience: undefined, //从业经验
		workYears: undefined, //工作年限
		sellerName: '四川敬善金美商务信息咨询有限公司', //售方名称
		cooperationMode: undefined, //合作模式
		possessorName: undefined, //持有人姓名
		relationshipApplicant: undefined, //与申请人关系
		possessCertificateType: undefined, //持有人证件类型
		possessCardId: undefined, //持有人证件号码
		lendingPolicy: undefined, //贷款政策
		getAttached: undefined, //是否靠挂
		productName: 1, //产品名称
		isMortgage: undefined, //是否抵押
		anxinLoan: undefined, //安心贷政策
		isSoftLoan: undefined, //是否贴息
		interestRateBracket: undefined, //差异化利率档次
		posApplicantAddress: undefined, //职业申请人单位地址
		posApplicantDtetailAddress: undefined, //职业申请人单位详情地址
		vehicleLoanOrderId: undefined, //贷款单号ID
		vehicleBusinessType: undefined, //车辆业务类型（0：新车，1：二手车）
		customerName: undefined, //客户姓名
		idCard: undefined, //身份证号
		issueAuthorityProvince: undefined, //上牌省份
		issueAuthorityCity: undefined, //上牌城市
		// vehicleDealers: undefined, //车商
		mobileNo: undefined, //手机号
		mile: undefined, //公里数
		// rate: undefined, //系数
		// loanAmount: undefined, //贷款金额
		loadInstalments: undefined, //贷款期数
		maritalStatus: undefined, //婚姻状况
		residentialAddress: undefined, //居住地址
		residentialDetailAddress: undefined, //居住详细地址
		workUnit: undefined, //工作单位
		workAddress: undefined, //单位地址
		workingYears: 1, //工作年限
		monthlyIncome: undefined, //本人月收入
		spouseName: undefined, //配偶姓名
		spouseIdCard: undefined, //配偶身份证号码
		spouseMobileNo: undefined, //配偶手机号码
		spouseMonthlyIncome: undefined, //配偶月收入
		relativeName: undefined, //亲友姓名
		relativeMobileNo: undefined, //亲友手机号码
		relationType: undefined, //与申请人关系
		otherRelativeName: undefined, //紧急联系人姓名
		otherRelativeMobileNo: undefined, //紧急联系人手机号码
		otherRelationType: undefined, //紧急联系人与申请人关系
		// drivingLicenseOwnerType: undefined, //驾驶证持有人信息
		idCardFace: [], //身份证正面文件
		idCardBack: [], //身份证反面文件
		drivingLicense: [], //驾驶证文件
		vehicleRegistrationCertificate: [], //车辆登记证书文件
		drivingPermit: [], //行驶证文件
		relationProof: [], //关系证明文件
		otherIncomeProof: [], //其他收入证明文件
	};

	let formData = ref({
		...formDefault
	});

	const rules = {
		// 车辆信息
		vehicleBusinessType: {
			rules: [{
				required: true,
				errorMessage: '车辆业务类型必填'
			}]
		},
		// vehicleDealers: {
		// 	rules: [{
		// 		required: true,
		// 		errorMessage: '车商信息必填'
		// 	}]
		// },  
		// drivingLicenseOwnerType: {
		// 	rules: [{
		// 		required: true,
		// 		errorMessage: '驾驶证持有人信息必填'
		// 	}]
		// },
		drivingLicense: {
			rules: [{
				required: true,
				errorMessage: '请上传驾驶证照片',
				trigger: 'change'
			}]
		},
		issueAuthorityProvince: {
			rules: []
		},
		issueAuthorityCity: {
			rules: []
		},
		mile: {
			rules: []
		},
		// rate: {
		// 	rules: []
		// },
		// loanAmount: {
		// 	rules: []
		// },
		loadInstalments: {
			rules: []
		},
		vehicleRegistrationCertificate: {
			rules: []
		},
		drivingPermit: {
			rules: []
		},
		// 学历
		educational: {
			rules: [{
				required: true,
				errorMessage: '学历必选项'
			}]
		},
		//单位电话
		workTelephone: {
			rules: [{
				required: true,
				errorMessage: '单位电话为必填项'
			}, {
				pattern: regular.phone,
				errorMessage: '请输入正确的手机号',
				trigger: 'blur'
			}, ]
		},
		//邮寄地址
		mailingAddress: {
			rules: [{
				required: true,
				errorMessage: '邮寄地址为必填项'
			}]
		},

		//本地户口
		localHouseholdRegistration: {
			rules: [{
				required: true,
				errorMessage: '本地户口为必选项'
			}]
		},

		//新市民
		newCitizen: {
			rules: [{
				required: true,
				errorMessage: '新市民为必选项'
			}]
		},
		//单位所属行业
		unitIndustry: {
			rules: [{
				required: true,
				errorMessage: '新市民为必选项'
			}]
		},
		// 从业经验
		workExperience: {
			rules: [{
				required: true,
				errorMessage: '从业经验为必选项'
			}]
		},
		// 工作年限
		workYears: {
			rules: [{
				required: true,
				errorMessage: '工作年限为必选项'
			}]
		},
		// 持有人姓名
		possessorName: {
			rules: [{
				required: true,
				errorMessage: '持有人姓名为必填项'
			}]
		},
		//与申请人关系
		relationshipApplicant: {
			rules: [{
				required: true,
				errorMessage: '与申请人关系为必选项'
			}]
		},
		// 持有人证件类型
		possessCertificateType: {
			rules: [{
				required: true,
				errorMessage: '持有人证件类型为必选项'
			}]
		},
		// 售方名称
		sellerName: {
			rules: [{
				required: true,
				errorMessage: '售方名称为必填项'
			}]
		},
		// 合作模式
		cooperationMode: {
			rules: [{
				required: true,
				errorMessage: '合作模式为必选项'
			}]
		},
		//持有人证件号码
		possessCardId: {
			rules: [{
				required: true,
				errorMessage: '证件号码为必填项'
			}]
		},
		// 贷款政策
		lendingPolicy: {
			rules: [{
				required: true,
				errorMessage: '贷款政策为必选项'
			}]
		},
		// 产品名称
		productName: {
			rules: [{
				required: true,
				errorMessage: '产品名称为必选项'
			}]
		},
		// 是否靠挂
		getAttached: {
			rules: [{
				required: true,
				errorMessage: '是否靠挂为必选项'
			}]
		},
		// 是否抵押
		isMortgage: {
			rules: [{
				required: true,
				errorMessage: '是否抵押'
			}]
		},
		// 安心贷政策
		anxinLoan: {
			rules: [{
				required: true,
				errorMessage: '是否安心贷'
			}]
		},
		// 是否贴息
		isSoftLoan: {
			rules: [{
				required: true,
				errorMessage: '贴息为必选项'
			}]
		},
		// 差异化利率档次
		interestRateBracket: {
			rules: [{
				required: true,
				errorMessage: '差异化利率档次必选项'
			}]
		},
		//职业申请人单位地址
		posApplicantAddress: {
			rules: [{
				required: true,
				errorMessage: '单位地址为必选项'
			}]
		},
		//职业申请人单位详情地址
		posApplicantDtetailAddress: {
			rules: [{
				required: true,
				errorMessage: '职业申请人单位详情地址为必填项'
			}]
		},

		// 客户信息
		customerName: {
			rules: [{
				required: true,
				errorMessage: '客户姓名为必填项'
			}]
		},
		mobileNo: {
			rules: [{
				required: true,
				errorMessage: '手机号为必填项'
			}, {
				pattern: regular.phone,
				errorMessage: '请输入正确的手机号',
				trigger: 'blur'
			}, ]
		},
		idCard: {
			rules: [{
				required: true,
				errorMessage: '身份证号 必填'
			}, {
				pattern: regular.isIdentityCard,
				errorMessage: '请输入正确的身份证号',
				trigger: 'blur'
			}]
		},
		maritalStatus: {
			rules: [{
				required: true,
				errorMessage: '婚姻状况为必填项'
			}]
		},
		residentialAddress: {
			rules: [{
				required: true,
				errorMessage: '居住地址为必填项'
			}]
		},

		residentialDetailAddress: {
			rules: [{
				required: true,
				errorMessage: '居住详细地址为必填项'
			}]
		},

		workUnit: {
			rules: [{
				required: true,
				errorMessage: '工作单位为必填项'
			}]
		},
		workAddress: {
			rules: [{
				required: true,
				errorMessage: '单位地址为必选项'
			}]
		},
		monthlyIncome: {
			rules: [{
				required: true,
				errorMessage: '本人月收入为必填项'
			}]
		},
		spouseName: {
			rules: []
		},
		spouseIdCard: {
			rules: []
		},
		spouseMobileNo: {
			rules: []
		},
		spouseMonthlyIncome: {
			rules: []
		},
		relativeName: {
			rules: [{
				required: true,
				errorMessage: '亲友姓名为必填项'
			}]
		},
		relativeMobileNo: {
			rules: [{
				required: true,
				errorMessage: '亲友手机号码为必填项'
			}, {
				pattern: regular.phone,
				errorMessage: '请输入正确的手机号',
				trigger: 'blur'
			}, ]
		},
		relationType: {
			rules: [{
				required: true,
				errorMessage: '与申请人关系为必选项'
			}]
		},
		otherRelativeName: {
			rules: [{
				required: true,
				errorMessage: '紧急联系人名称为必填项'
			}]
		},
		otherRelativeMobileNo: {
			rules: [{
				required: true,
				errorMessage: '紧急联系人手机号码为必填项'
			}, {
				pattern: regular.phone,
				message: '请输入正确的手机号',
				trigger: 'blur'
			}, ]
		},
		otherRelationType: {
			rules: [{
				required: true,
				errorMessage: '紧急联系人与申请人关系为必填项'
			}]
		},
		idCardFace: {
			rules: [{
				required: true,
				errorMessage: '请上身份证正面照片',
				trigger: 'change'
			}, ]
		},
		idCardBack: {
			rules: [{
				required: true,
				errorMessage: '请上身份证反面照片',
				trigger: 'change'
			}, ]
		}
	};
	// 数据定义(工作单位)
	const dataTree2 = ref([])
	// 获取省下拉数据(工作单位)
	async function getMapDataFun2(params) {
		let res = await vehicleLoanOrderApi.getMapDataApi(params)
		provinceData2.value = res.data.map(it => {
			return {
				text: it.provinceName,
				value: it.provinceCode,
				leve: it.provinceId,
				type: it.type
			}
		})
	}
	// 获取市下拉数据(工作单位)
	async function getCityDataFun2(params) {
		let res = await vehicleLoanOrderApi.getMapDataApi(params)
		console.log(res.data, '过去市的数据');
		cityData2.value = res.data.map(it => {
			return {
				text: it.cityName,
				value: it.cityCode,
				leve: it.provinceId,
				type: it.type
			}
		})
		console.log(res.data, 'resres');
	}
	// 获取区下拉数据(工作单位)
	async function getareaDataFun2(params) {
		let res = await vehicleLoanOrderApi.getMapDataApi(params)
		areaData2.value = res.data.map(it => {
			return {
				text: it.areaName,
				value: it.areaCode,
				leve: it.provinceId,
				type: it.type
			}
		})
		console.log(res.data, 'resres');
	}
	// 获取街道下拉数据(工作单位)
	async function getstreetDataFun2(params) {
		let res = await vehicleLoanOrderApi.getMapDataApi(params)
		streetData2.value = res.data.map(it => {
			return {
				text: it.streetName,
				value: it.streetCode,
				leve: it.streetName,
				type: it.type
			}
		})
		console.log(res.data, 'resres');
	}


	// 选择某省(工作单位)
	const provincechange2 = (e) => {
		let s = provinceData2.value.filter(items => e == items.value)
		dataTree2.value[0] = {
			value: s[0].value,
			label: s[0].text,
		}
		getCityDataFun2({
			type: "2", // 1: 省份，2：市，3：区县 4：街道
			provinceCode: e,
			cityCode: "", // 市代码
			areaCode: "", // 区县代码
		})
	}
	// 选择某市(工作单位)
	const citychange2 = (e) => {
		let s = cityData2.value.filter(items => e == items.value)
		dataTree2.value[1] = {
			value: s[0].value,
			label: s[0].text,
		}
		getareaDataFun2({
			type: "3", // 1: 省份，2：市，3：区县 4：街道
			provinceCode: "",
			cityCode: e, // 市代码
			areaCode: "", // 区县代码
		})
	}

	// 选择某区(工作单位)
	const areachange2 = (e) => {
		let s = areaData2.value.filter(items => e == items.value)
		dataTree2.value[2] = {
			value: s[0].value,
			label: s[0].text,
		}
		getstreetDataFun2({
			type: "4", // 1: 省份，2：市，3：区县 4：街道
			provinceCode: "",
			cityCode: "", // 市代码
			areaCode: e, // 区县代码
		})
	}


	// 选择街道(工作单位)
	const streetchange2 = (e) => {
		let s = streetData2.value.filter(items => e == items.value)
		dataTree2.value[3] = {
			value: s[0].value,
			label: s[0].text,
		}
		// 去重 + 提取 value
		const uniqueValues = [...new Set(dataTree2.value.map(item => item.value))];
		// 拼接成字符串
		const result = uniqueValues.join("，");
		formData.value.posApplicantAddress = result
	}


	watchEffect(() => {
		if (formData.value.vehicleBusinessType === 1) {
			queryProvinceZone();
			rules.issueAuthorityProvince.rules = [{
				required: true,
				errorMessage: '请填写上牌省份'
			}];
			rules.issueAuthorityCity.rules = [{
				required: true,
				errorMessage: '请填写上牌城市'
			}];
			rules.mile.rules = [{
				required: true,
				errorMessage: '请填写公里'
			}];
			// rules.rate.rules = [{
			// 	required: true,
			// 	errorMessage: '请填写系数'
			// }];
			// rules.loanAmount.rules = [{
			// 	required: true,
			// 	errorMessage: '请填写贷款金额'
			// }];
			rules.loadInstalments.rules = [{
				required: true,
				errorMessage: '请填写贷款期数'
			}];
			rules.vehicleRegistrationCertificate.rules = [{
				required: true,
				errorMessage: '请上传车辆登记证书照片',
				trigger: 'change'
			}];
			rules.drivingPermit.rules = [{
				required: true,
				errorMessage: '请上传行使证照片',
				trigger: 'change'
			}, ];
		} else {
			rules.issueAuthorityProvince.rules = [];
			rules.issueAuthorityCity.rules = [];
			rules.mile.rules = [];
			rules.rate.rules = [];
			rules.loanAmount.rules = [];
			rules.loadInstalments.rules = [];
			rules.vehicleRegistrationCertificate.rules = [];
			rules.drivingPermit.rules = [];
		}

		if (formData.value.maritalStatus === '9105') {
			rules.spouseName.rules = [{
				required: true,
				errorMessage: '请填写配偶姓名'
			}];
			rules.spouseIdCard.rules = [{
				required: true,
				errorMessage: '请填写配偶身份证号码'
			}, {
				pattern: regular.isIdentityCard,
				errorMessage: '请输入正确的身份证号',
				trigger: 'blur'
			}];
			rules.spouseMobileNo.rules = [{
				required: true,
				errorMessage: '请填写配偶手机号码'
			}, {
				pattern: regular.phone,
				errorMessage: '请输入正确的手机号',
				trigger: 'blur'
			}, ];
			rules.spouseMonthlyIncome.rules = [{
				required: true,
				errorMessage: '请填写配偶月收入'
			}];
		} else {
			rules.spouseName.rules = [];
			rules.spouseIdCard.rules = [];
			rules.spouseMobileNo.rules = [];
			rules.spouseMonthlyIncome.rules = [];
		}
	})

	// 确定
	// 添加提交状态标记
	const submitting = ref(false);

	// 修改提交方法
	function ok() {
		console.log(formData.value.residentialAddress);
		// 如果正在提交中,直接返回
		if (submitting.value) {
			return;
		}

		formRef.value
			.validate()
			.then(async () => {
				submitting.value = true; // 设置提交状态
				SmartLoading.show();
				try {
					await vehicleLoanOrderApi.add(formData.value);
					SmartToast.success('添加成功');
				} catch (error) {
					smartSentry.captureError(error);
				} finally {
					SmartLoading.hide();
					submitting.value = false; // 重置提交状态
				}
			})
			.catch((error) => {
				console.log('error', error);
				SmartToast.toast('参数验证错误，请仔细填写表单数据!');
			});
	}
	// 数据定义(现居住地址)
	const dataTree = ref([])
	// 获取省下拉数据(现居住地址)
	async function getMapDataFun(params) {
		let res = await vehicleLoanOrderApi.getMapDataApi(params)
		provinceData.value = res.data.map(it => {
			return {
				text: it.provinceName,
				value: it.provinceCode,
				leve: it.provinceId,
				type: it.type
			}
		})
		console.log(res.data, 'resres');
	}
	// 获取市下拉数据(现居住地址)
	async function getCityDataFun(params) {
		let res = await vehicleLoanOrderApi.getMapDataApi(params)
		cityData.value = res.data.map(it => {
			return {
				text: it.cityName,
				value: it.cityCode,
				leve: it.provinceId,
				type: it.type
			}
		})
	}
	// 获取区下拉数据(现居住地址)
	async function getareaDataFun(params) {
		let res = await vehicleLoanOrderApi.getMapDataApi(params)
		areaData.value = res.data.map(it => {
			return {
				text: it.areaName,
				value: it.areaCode,
				leve: it.provinceId,
				type: it.type
			}
		})
		console.log(res.data, 'resres');
	}
	// 获取街道下拉数据(现居住地址)
	async function getstreetDataFun(params) {
		let res = await vehicleLoanOrderApi.getMapDataApi(params)
		streetData.value = res.data.map(it => {
			return {
				text: it.streetName,
				value: it.streetCode,
				leve: it.streetName,
				type: it.type
			}
		})
	}


	onMounted(() => {
		getMapDataFun({
			type: "1", // 1: 省份，2：市，3：区县 4：街道
			provinceCode: "",
			cityCode: "", // 市代码
			areaCode: "", // 区县代码
		})
		getMapDataFun2({
			type: "1", // 1: 省份，2：市，3：区县 4：街道
			provinceCode: "",
			cityCode: "", // 市代码
			areaCode: "", // 区县代码
		})
	})
	// 选择某省(现居住地址)
	const provincechange = (e) => {
		let s = provinceData.value.filter(items => e == items.value)
		dataTree.value[0] = {
			value: s[0].value,
			label: s[0].text,
		}
		getCityDataFun({
			type: "2", // 1: 省份，2：市，3：区县 4：街道
			provinceCode: e,
			cityCode: "", // 市代码
			areaCode: "", // 区县代码
		})
	}
	// 选择某市(现居住地址)
	const citychange = (e) => {
		let s = cityData.value.filter(items => e == items.value)
		dataTree.value[1] = {
			value: s[0].value,
			label: s[0].text,
		}
		getareaDataFun({
			type: "3", // 1: 省份，2：市，3：区县 4：街道
			provinceCode: "",
			cityCode: e, // 市代码
			areaCode: "", // 区县代码
		})
	}

	// 选择某区(现居住地址)
	const areachange = (e) => {
		let s = areaData.value.filter(items => e == items.value)
		dataTree.value[2] = {
			value: s[0].value,
			label: s[0].text,
		}
		getstreetDataFun({
			type: "4", // 1: 省份，2：市，3：区县 4：街道
			provinceCode: "",
			cityCode: "", // 市代码
			areaCode: e, // 区县代码
		})
	}

	// 选择街道(现居住地址)
	const streetchange = (e) => {
		let s = streetData.value.filter(items => e == items.value)
		dataTree.value[3] = {
			value: s[0].value,
			label: s[0].text,
		}
		// 去重 + 提取 value
		const uniqueValues = [...new Set(dataTree.value.map(item => item.value))];
		// 拼接成字符串
		const result = uniqueValues.join("，");
		formData.value.residentialAddress = result
	}
</script>

<style lang="scss" scoped>
	.smart-filed {
		:deep(.uni-forms-item) {
			margin-top: 30rpx !important;
		}

		:deep(.uni-forms-item__label:nth-child(7)) {
			padding: 38px 12px 0 0 !important;
		}


	}

	.smart-form-item {
		margin-top: 20rpx !important;
	}
</style>